package com.example.project.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.example.project.entity.IssueStatus;

/**
 * 问题状态，定义问题的可能状态Mapper接口
 * 
 * @author ruoyi
 * @date 2025-09-19
 */
@Mapper
public interface IssueStatusMapper {

	/**
	 * 查询问题状态，定义问题的可能状态
	 * 
	 * @param id 问题状态，定义问题的可能状态主键
	 * @return 问题状态，定义问题的可能状态
	 */
	@Select("select id, name, is_closed, is_default, html_color from t_issue_status where id = #{id}")
	public IssueStatus selectIssueStatusById(Long id);

	/**
	 * 查询问题状态，定义问题的可能状态列表
	 * 
	 * @param tIssueStatus 问题状态，定义问题的可能状态
	 * @return 问题状态，定义问题的可能状态集合
	 */
	@Select({ "<script>", "select id, name, is_closed, is_default, html_color from t_issue_status", "<where>",
			"<if test=\"name != null and name != ''\"> and name like concat('%', #{name}, '%')</if>",
			"<if test=\"isClosed != null\"> and is_closed = #{isClosed}</if>",
			"<if test=\"isDefault != null\"> and is_default = #{isDefault}</if>",
			"<if test=\"htmlColor != null and htmlColor != ''\"> and html_color = #{htmlColor}</if>", "</where>",
			"</script>" })
	public List<IssueStatus> selectIssueStatusList(IssueStatus tIssueStatus);

	/**
	 * 新增问题状态，定义问题的可能状态
	 * 
	 * @param tIssueStatus 问题状态，定义问题的可能状态
	 * @return 结果
	 */
	@Insert({ "<script>", "insert into t_issue_status", "<trim prefix=\"(\" suffix=\")\" suffixOverrides=\",\">",
			"<if test=\"name != null and name != ''\">name,</if>", "<if test=\"isClosed != null\">is_closed,</if>",
			"<if test=\"isDefault != null\">is_default,</if>",
			"<if test=\"htmlColor != null and htmlColor != ''\">html_color,</if>", "</trim>",
			"<trim prefix=\"values (\" suffix=\")\" suffixOverrides=\",\">",
			"<if test=\"name != null and name != ''\">#{name},</if>", "<if test=\"isClosed != null\">#{isClosed},</if>",
			"<if test=\"isDefault != null\">#{isDefault},</if>",
			"<if test=\"htmlColor != null and htmlColor != ''\">#{htmlColor},</if>", "</trim>", "</script>" })
	public int insertIssueStatus(IssueStatus tIssueStatus);

	/**
	 * 修改问题状态，定义问题的可能状态
	 * 
	 * @param tIssueStatus 问题状态，定义问题的可能状态
	 * @return 结果
	 */
	@Update({ "<script>", "update t_issue_status", "<trim prefix=\"SET\" suffixOverrides=\",\">",
			"<if test=\"name != null and name != ''\">name = #{name},</if>",
			"<if test=\"isClosed != null\">is_closed = #{isClosed},</if>",
			"<if test=\"isDefault != null\">is_default = #{isDefault},</if>",
			"<if test=\"htmlColor != null and htmlColor != ''\">html_color = #{htmlColor},</if>", "</trim>",
			"where id = #{id}", "</script>" })
	public int updateIssueStatus(IssueStatus tIssueStatus);

	/**
	 * 删除问题状态，定义问题的可能状态
	 * 
	 * @param id 问题状态，定义问题的可能状态主键
	 * @return 结果
	 */
	@Delete("delete from t_issue_status where id = #{id}")
	public int deleteIssueStatusById(Long id);

	/**
	 * 批量删除问题状态，定义问题的可能状态
	 * 
	 * @param ids 需要删除的数据主键集合
	 * @return 结果
	 */
	@Delete({ "<script>", "delete from t_issue_status where id in",
			"<foreach item=\"id\" collection=\"array\" open=\"(\" separator=\",\" close=\")\">", "#{id}", "</foreach>",
			"</script>" })
	public int deleteIssueStatusByIds(String[] ids);

	@Select("select id, name, is_closed, is_default, html_color from t_issue_status")
	public List<IssueStatus> selectIssueStatusAll();
}
